<!--
 * @Descripttion: 
 * @version: 
 * @Author: weihua.yao
 * @Date: 2021-04-13 00:22:38
 * @LastEditTime: 2021-04-13 00:33:14
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <canvas id="canvas" width="800" height="800"></canvas>
  <script>
    const canvas = document.getElementById('canvas')
    const ctx = canvas.getContext('2d') //获取cavans对象
    ctx.fillStyle = 'red'
    ctx.fillRect(0, 0, 50, 50)

    ctx.beginPath();
    ctx.lineWidth =2;
    ctx.storkeStyle = 'blue'
    ctx.moveTo(100, 100,)
    ctx.lineTo(250, 250)
    ctx.lineTo(250, 150)
    ctx.lineTo(150, 250)
    ctx.stroke();

    ctx.beginPath();
    ctx.lineWidth =2;
    ctx.fillStyle='green'
    ctx.arc(300,300,50,0,2*Math.PI)
    ctx.stroke();
    ctx.fill()
  </script>
</body>

</html>